package bman.game.battletank;

import bman.game.engine.Entity;
import bman.game.engine.Timer;

public class ProjectileAnimator extends Thread
{
	Entity ent = null;
	BattleTank re = null;
	
	long timeToLive = 1500;
	long start = 0;
	
	public ProjectileAnimator(Entity e, BattleTank re)
	{
		ent = e;
		start();
		start = System.currentTimeMillis();
		this.re = re;
	}
	
	public void run()
	{
		long elapsed = 0;
		
		try
		{
			Timer t = new Timer();
			
			while(timeToLive > elapsed && ent.isActive())
			{
				t.update();
				re.process("MOVE "+ent.getBearing(), ent);
				elapsed = System.currentTimeMillis() - start;
				sleep(t.getSleep());
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}

		re.process("DISAPPEAR", ent);
	}
	

}
